﻿/// <reference name="MicrosoftAjax.js"/>
/// <reference path="Longbow.UI.HyperlinkBehavior.js" />
/// <reference path="Gammar.Price.PagerControl.js" />

function goDetail(guid, counter) {
    var pageUrl = counter > 1 ? "TLP/ComparePrice.aspx?id={0}" : "TLP/Default.aspx?id={0}";
    window.open(String.format(pageUrl, guid), "_blank");
}

function sLoad() {
    var url = document.location.search;
    var pageIndex = $getParameter(url, "pid");
    pageIndex = pageIndex.length > 0 ? Number.parseInvariant(pageIndex) : 0;
    
    var pageSize = 10;
    var dataCount = 0;
    var div = $get('sc');
    var scc = div.getElementsByTagName("TABLE");
    if (scc.length > 0 && scc[0].getAttribute("dc")) {
        dataCount = scc[0].getAttribute("dc");
        dataCount = dataCount.length > 0 ? Number.parseInvariant(dataCount) : 0;
    }
    
    if (dataCount === 0) {
        div.innerHTML = "未找到相关数据！请您更改搜索关键字后再试";
    }
    
    $create(Gammar.Price.Web.PagerControl, 
        {DataCount: dataCount, PageIndex: pageIndex, PageSize: pageSize}, 
        {pageClick: pageClick}, 
        null, $get('tPager'));
    $create(Gammar.Price.Web.PagerControl, 
        {DataCount: dataCount, PageIndex: pageIndex, PageSize: pageSize}, 
        {pageClick: pageClick}, 
        null, $get('bPager'));
}

function pageClick(eventObject, pageClickEventArgs) {
    //eventObject.target.href = $addParameter(document.location.href, "pid", pageClickEventArgs.pageIndex);
    window.location.href = $addParameter(document.location.href, "pid", pageClickEventArgs.pageIndex);
}

Sys.Application.add_load(sLoad);